import { LOADDATA } from './actionTypes'
import {  post } from '@u/http.js'



const loadDataSync = list => {
  return {
    type:LOADDATA,
    list
  }
}

const loadDataAsync = (data) => {
  console.log(data)
  return async (dispatch) => {
    let result = await post({
      url:'/api/login'
    },
    {
      data:data
    })
    console.log(result)
    sessionStorage.setItem('username','')
    console.log(sessionStorage.username)
    if(result.code===0 && result.msg==='登录成功'){
      console.log(0);
      sessionStorage.setItem('username',JSON.stringify(result.usUser))
    }
  }
}


// {
//   "zhanghao":"12345@qq.com",
//   "password":"123456",
//   "renzheng":1,
//   "rememberMe":1
// }

export {
  loadDataSync,
  loadDataAsync
}